package com.it2297.renderer;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.table.TableCellRenderer;

import java.awt.Color;
import java.awt.Component;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;


import com.it2297.model.Job;
import com.it2297.model.Product;

public class JobApplicantsCellRenderer extends JLabel implements TableCellRenderer {

	private Job job;
	
	/**
	 * Create the panel.
	 */
	public JobApplicantsCellRenderer() {
		setOpaque(true);
		setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
		setVerticalTextPosition(JLabel.TOP);
		setIconTextGap(10);
	}

	public Component getTableCellRendererComponent(JTable table, Object object, boolean isSelected, boolean hasFocus, int row, int column) {
		job = (Job) object;
		
		switch(column){
		case 0:
			String currentWorkingDirectory = System.getProperty("user.dir");
			setIcon(new ImageIcon(currentWorkingDirectory+"/img/Job/arrowhead.png"));
			setText("<html><ol><li></li></ol></html>");
			break;
			
		case 1:
			setIcon(null);
			setText("<html><ul><u>Application Details:</u> <li>Applicant: " + job.getApplicantName() + " (" + job.getApplicantNRIC() + ") </li><li> Applicant Phone: " + job.getPhone() + "</li> <li>Applicant Email: " + job.getEmail() + "</li> <li>Additional Information: " + job.getAdditionalInformation() + " </li><li>Date Of Application: " + job.getDate()+"</li></html>");
			break;
		}
		
		if(row % 2 ==0){
		//setBackground(new Color(176,196,222));
		setBackground(new Color(240, 240, 240));
			//	setBackground(Color.WHITE);
		}else{
			//setBackground(new Color(240, 240, 240));
			setBackground(new Color(176,196,222));
		}
		
		setForeground(Color.BLACK);
		
		if(isSelected){
			setForeground(new Color(255,255,255));
			setBackground(new Color(80,80,80));
		}
		
		return this;
	}

}
